var xhr = null;
// XMLHttpRequest : CrossBrowser, ActiveXObject : Internet Explorer
function createRequest() {
	if (window.ActiveXObject) {
		xhr = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		xhr = new XMLHttpRequest();
	}
}

function sendRequest(url, param, callback, method) {
	createRequest();
	var httpMethod = (method != 'POST' && method != 'post') ? 'GET' : 'POST';
	var httpParam = (param == null || param == '') ? null : param;
	var httpURL = url;
	if (httpMethod == 'GET' && httpParam != null) {
		httpURL = httpURL + "?" + httpParam; // test.jsp?idx=12
	}
	xhr.onreadystatechange = callback;
	xhr.open(httpMethod, httpURL, true);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send(httpMethod == 'POST' ? httpParam : null);
}

function checkSearchQuery(form) {
	if (form.query.value.length < 3) {
		alert("Please type more than 2 words");
		return (false);
	}

	return true;
}

function chkcontrol(form) {
	var counter = 0;
	var i = 0;
	var uid = FB.getSession().uid;
	var url = '';
	var confirmation = false;
	
	for (i = 0; i < document.genre.genre.length; i++) {
		if (document.genre.genre[i].checked == true) {
			counter++;
			url = url + '&genre=' + document.genre.genre[i].value;
		}
	}
	
	if (counter != 5) {
		confirmation = false;
	} else {
		confirmation = true;
	}
	
	if (!confirmation) {
		alert("Please seleect 5 genres only.");
		return confirmation;
		
	} else {
		location.href = "/LaSeC/Genre?uid=" + uid + url;
	}
}

function AJAXresult() {
	if (xhr.readyState == 4) {
		if (xhr.status == 200) {
		}
	}
}